<@override name="content">
<div class="header" xmlns="http://www.w3.org/1999/html">
  <h1 class="page-title">日志文件</h1>
</div>
<ul class="breadcrumb">
  <li>
    <a href="admin">首页</a>
    <span class="divider">/</span>
  </li>
  <li>
    <a href="admin/file/logs">文件管理</a>
    <span class="divider">/</span>
  </li>
</ul>
<div class="container-fluid">
  <div class="row-fluid">
    <div class="well">
      <div id="container">
        <h4>View Log:
          <a href="admin/file/download/?dir=${dir!?url}&name=${name!?url}&type=log">
            <#if dir?? && dir?has_content>${dir!}/</#if>${name!}
          </a>
        </h4>
        <div>
          <textarea id="content" rows="40" cols="200" wrap="soft"></textarea>
        </div>
      </div>
    </div>
  </div>
</div>
</@override>
<@override name="styles">
<style>
  textarea {
    width: auto;
  }
</style>
</@override>
<@override name="scripts">
<script type="text/javascript">
  $(document).ready(function () {
    var page = 0;
    var size = 40;
    function getLog(page, size) {
      var url = '/api/admin/log';
      $.getJSON(url, {'dir': '${dir!}', 'name': '${name!}', 'page': page, 'size': size}, function (data) {
        var content = $('#content').val() + data.content;
        if (isEmpty(data.content)) {
          page = -1;
        }
        $('#content').val(content);
      });
    }

    getLog(page, size);
    $('#content').scroll(function() {
      if(this.scrollHeight <= $('#content').scrollTop() + $('#content').height() + 10) {
        page = page + 1;
        getLog(page, size);
      }
    });
  });
</script>
</@override>
<@extends name="../_layout.html"></@extends>
